package com.maxlen.coupon.controller;

import com.maxlen.common.utils.PageUtils;
import com.maxlen.common.utils.R;
import com.maxlen.coupon.entity.SeckillSessionTimeEntity;
import com.maxlen.coupon.service.SeckillSessionTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 秒杀活动场次
 *
 * @author MaxLen
 * @email MaxLen@gmail.com
 * @date 2022-10-27 10:43:47
 */
@RestController
@RequestMapping("coupon/seckillsessiontime")
public class SeckillSessionTimeController {
    @Autowired
    private SeckillSessionTimeService seckillSessionTimeService;

    /**
     * 列表
     */
    @PostMapping("/list")
    // @RequiresPermissions("coupon:seckillsession:list")
    public R list(@RequestBody Map<String, Object> params){
        PageUtils page = seckillSessionTimeService.queryPage(params);

        return R.ok().setData(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    // @RequiresPermissions("coupon:seckillsession:info")
    public R info(@PathVariable("id") Long id){
		SeckillSessionTimeEntity seckillSession = seckillSessionTimeService.getById(id);
        System.out.println(seckillSession);
        return R.ok().setData(seckillSession);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    // @RequiresPermissions("coupon:seckillsession:save")
    public R save(@RequestBody SeckillSessionTimeEntity seckillSession){
        seckillSessionTimeService.save(seckillSession);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    // @RequiresPermissions("coupon:seckillsession:update")
    public R update(@RequestBody SeckillSessionTimeEntity seckillSession){
        seckillSessionTimeService.updateById(seckillSession);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    // @RequiresPermissions("coupon:seckillsession:delete")
    public R delete(@RequestBody Long[] ids){
        seckillSessionTimeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
